home *** CD-ROM | disk | FTP | other *** search
- /*-------------------------------------------------------------------------------------
- *
- * IPM MessageBoard AOCE Sample
- *
- * ©1992-1993 Apple Computer
- *
- -------------------------------------------------------------------------------------*/
- /*
- * commands.c -- called in response to menu commands or appleevents
- *
- * change history:
- *
- * SJF 2/12/93 1.0b1 udpate to AOCE beta seed
- * SJF 11/6/91 1.0d1 initial coding
- *
- */
-
- #ifndef __TYPES__
- #include <Types.h>
- #endif
-
- #ifndef __DIALOGS__
- #include <Dialogs.h>
- #endif
-
- #include "const.h"
- #include "mymenus.h"
- #include "globals.h"
- #include "utils.h"
- #include "statusdialog.h"
- #include "myipm.h"
-
- #include "commands.h"
-
-
- /* show about box */
-
- void CommAbout(void)
- {
- DialogPtr theDlg;
- short item;
-
- theDlg = GetNewDialog(kAboutBoxID,nil,kInFront);
- do {
- ModalDialog(nil,&item);
- } while (item!=ok);
-
- DisposDialog(theDlg);
- }
-
-
- void CommMakeMessage(void)
- {
- Str255 newMessage;
-
- if (gNumMessages==kMaxMessages) {
- SysBeep(1);
- return;
- }
-
- newMessage[0] = '\0';
- if (EditMessage(newMessage)) {
- pstrcpy(gMessageList[gNumMessages],newMessage);
- AddItemToList(gNumMessages,kMsgListDItem);
- gNumMessages++;
- }
- }
-
-
- Boolean GetQueueName(StringPtr msgText)
- {
- DialogPtr theDlg;
- short iType;
- Handle iHndl;
- Rect iRect;
- short item;
-
- theDlg = GetNewDialog(kQNameEditBox,nil,kInFront);
- GetDItem(theDlg,kQNameTextDItem,&iType,&iHndl,&iRect);
- SetIText(iHndl,msgText);
- SelIText(theDlg,kQNameTextDItem,0,32767);
-
- do {
- ModalDialog(nil,&item);
- } while (item!=ok && item!=cancel);
-
- if (item==ok)
- GetIText(iHndl,msgText);
-
- DisposeDialog(theDlg);
-
- return (item==ok);
- }
-
-
- void CommMakeDestination(void)
- {
- OSErr err;
- Str32 qName;
-
- switch (gRadioBtnSelected)
- {
- case kAtalkAddrBtn:
- err = GetIPMDestination(&gDestList[gNumDestinations]);
- break;
- case kCreateServerQBtn:
- qName[0] = 0;
- if (GetQueueName((StringPtr)&qName))
- err = MyCreateQueue((StringPtr)&qName,&gDestList[gNumDestinations]);
- break;
- case kOpenServerQBtn:
- qName[0] = 0;
- if (GetQueueName((StringPtr)&qName))
- err = OpenQueueOnRemoteMachine((StringPtr)&qName,&gDestList[gNumDestinations]);
- break;
- case kPrefMsgQBtn:
- err = GetSingleAttrForRecipient(&gDestList[gNumDestinations],kPrefMsgQAttrTypeNum);
- break;
- case kMailSlotBtn:
- err = GetSingleAttrForRecipient(&gDestList[gNumDestinations],kPrefMailAttrTypeNum);
- break;
-
- }
-
- if (err==noErr) {
- AddItemToList(gNumDestinations,kDestListDItem);
- gNumDestinations++;
- }
- else if (err!=kUserCancelled)
- DoError(err);
- }
-
-
- void CommViewMessage(short msgNum)
- {
- Str255 newMessage;
-
- if (msgNum<0) {
- SysBeep(1);
- return;
- }
-
- pstrcpy(newMessage,gMessageList[msgNum]);
- if (EditMessage(newMessage)) {
- pstrcpy(gMessageList[msgNum],newMessage);
- EditItemInList(msgNum,kMsgListDItem);
- }
- }
-
-
- void CommSendMessage(short msgNum,short destNum)
- {
- OSErr err;
-
- if (msgNum<0 || destNum<0) {
- SysBeep(1);
- return;
- }
-
- err = SendIPMMessage(gMessageList[msgNum],gDestList[destNum]);
- if (err!=noErr)
- DoError(err);
- }
-
-
- Boolean EditMessage(StringPtr msgText)
- {
- DialogPtr theDlg;
- short iType;
- Handle iHndl;
- Rect iRect;
- short item;
-
- theDlg = GetNewDialog(kEditTextBoxID,nil,kInFront);
- GetDItem(theDlg,kTextDItem,&iType,&iHndl,&iRect);
- SetIText(iHndl,msgText);
- SelIText(theDlg,kTextDItem,0,32767);
-
- do {
- ModalDialog(nil,&item);
- } while (item!=ok && item!=cancel);
-
- if (item==ok)
- GetIText(iHndl,msgText);
-
- DisposeDialog(theDlg);
-
- return (item==ok);
- }